home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-10-26 | 3.8 KB | 140 lines | [TEXT/MPS ] |
- // Copyright © 1995 Apple Computer, Inc. All rights reserved.
- // Release Version: $ 1.0 d11 $
-
- //=======================================================================
-
- // --- DU Selection FW ---------------------
- #ifndef DULISTFRAME_H
- #include "DUListFrame.h" // DU_CListFrame
- #endif
-
- #ifndef DULISTPART_H
- #include "DUListPart.h" // DU_CListPart
- #endif
-
- #ifndef DULIST_H
- #include "DUList.h" // DU_CList, DU_CListIterator
- #endif
-
- #ifndef DULISTSELECTION_H
- #include "DUListSelection.h" // DU_CListSelection
- #endif
-
- // ----- Framework Layer -----
- #ifndef FWUTIL_H
- #include "FWUtil.h" // FW_CFacetContext, FW_Beep()
- #endif
-
- #ifndef FWVIEW_H
- #include "FWView.h" // FW_CViewContext
- #endif
-
- // ----- Graphic Includes -----
- #ifndef FWRECT_H
- #include <FWRect.h> // FW_CRect
- #endif
-
- #ifndef FWRECSHP_H
- #include "FWRecShp.h" // FW_CRectShape
- #endif
-
- //========================================================================================
- #ifdef FW_BUILD_MAC
- #pragma segment DUList
- #endif
-
- //========================================================================================
- DU_CListFrame::DU_CListFrame(Environment* ev, ODFrame* odFrame,
- FW_CPresentation* presentation, DU_CListPart* part)
- : FW_CFrame(ev, odFrame, presentation, part),
- fListPart(part),
- fSelection((DU_CListSelection*)GetPresentation(ev)->GetSelection(ev))
- {
- }
-
- //----------------------------------------------------------------------------------------
- DU_CListFrame::~DU_CListFrame()
- {
- }
-
- //----------------------------------------------------------------------------------------
- void
- DU_CListFrame::Draw(Environment *ev, ODFacet* odFacet, ODShape* invalidShape) // Override
- {
- FW_CViewContext vc(ev, this, odFacet, invalidShape);
- // FW_CRect box;
- // this->GetFrameShapeBounds(ev, box);
- FW_CRect box = this->GetBounds(ev);
-
- FW_CRectShape::RenderRect(vc, box, FW_kFill, FW_kRGBLightGray);
-
- // draw items
- DU_CList* list = fListPart->GetItemList();
- DU_CListIterator iter(list);
- DU_MSelectable* item;
- for (item = iter.First(); iter.IsNotComplete(); item = iter.Next()) {
- item->Draw(vc);
- item->DrawSelectionFeedback(vc);
- }
- }
-
- //--------------------------------------------------------------------------------
- FW_Boolean
- DU_CListFrame::DoAdjustMenus(Environment* ev, FW_CMenuBar* menuBar,
- FW_Boolean hasMenuFocus,
- FW_Boolean isRoot) // Override
- {
- if (hasMenuFocus) {
- }
- return FALSE;
- }
-
- //--------------------------------------------------------------------------------
- FW_Boolean
- DU_CListFrame::DoMenu(Environment* ev, const FW_CMenuEvent& theMenuEvent) // Override
- {
- FW_Boolean menuHandled = TRUE;
- switch (theMenuEvent.GetCommandID(ev)) {
-
- default:
- menuHandled = FALSE;
- }
- return menuHandled;
- }
-
- //----------------------------------------------------------------------------------------
- FW_Boolean
- DU_CListFrame::DoMouseDown(Environment* ev, const FW_CMouseEvent& theMouseEvent)
- {
- this->SelectItemWithMouse(ev, theMouseEvent);
- return TRUE; // we handled event
- }
-
- //----------------------------------------------------------------------------------------
- void
- DU_CListFrame::SelectItemWithMouse(Environment *ev, const FW_CMouseEvent& theMouseEvent)
- {
- FW_CPoint position = theMouseEvent.GetMousePosition(ev, FW_CMouseEvent::kFrame);
- this->GetContentView(ev)->FrameToViewContent(ev, position);
- DU_MSelectable* hitItem = fListPart->FrontItemHit(ev, position);
- if (hitItem) {
- if ( ! theMouseEvent.IsExtendModifier(ev) ) { // normal click
- if ( hitItem->IsSelected() )
- ; // do nothing
- else {
- fSelection->CloseSelection(ev);
- fSelection->AddItemToSelection(ev, hitItem);
- }
- }
- else { // shift-click
- if ( hitItem->IsSelected() )
- fSelection->RemoveItemFromSelection(ev, hitItem);
- else
- fSelection->AddItemToSelection(ev, hitItem);
- }
- }
- else
- if ( ! theMouseEvent.IsExtendModifier(ev) )
- fSelection->CloseSelection(ev);
- }
-